<template>
    <picker mode="date" :value="dateday" @change="bindDateChange($event, index)">
        <view class="uni-input">{{ dateday }}</view>
    </picker>
</template>

<script>
import utils from "@/utils/utils.js"
export default {
    props: {
        data: {
            // 数据
            type: Array,
        },
        index: {
            type: Number,
            default: 0,
        },
        date: {
            type: String,
            default: "",
        },
    },
    data() {
        return {
            dateday: "",
        }
    },
    mounted() {
        if (!this.date) {
            this.dateday = utils.getDate({
                format: true,
            })
        } else {
            this.dateday = this.date
        }
    },
    methods: {
        bindDateChange: function (e, index) {
            this.dateday = e.target.value
            this.$emit("bindDateChange", index, this.dateday)
        },
    },
}
</script>

<style lang="scss">
.checkmain {
    display: flex;
    flex-wrap: wrap;

    label {
        display: flex;
        width: 50%;

        view {
            white-space: nowrap;
        }
    }
}
</style>
